<%@ include file="/WEB-INF/jsp/include.jsp"%>
<%@page import="myicesscheduler.web.LoginController"%>

<table width="760" border="0" background="img/background4.gif">
  <tr>
    <td align="center">
    <h4>Hosted by: <c:out value="${lectureTimeSlot.lecture.lectureSponsor.name}" /></h4>
    <h1><c:out value="${lectureTimeSlot.lecture.speaker.name}" /></h1>
    <h3><c:out value="${lectureTimeSlot.lecture.speaker.organization}" /></h3>
    <h2><c:out value="${lectureTimeSlot.lecture.topic}" /></h2>
    <h3 class="notice"><c:out value="${lectureTimeSlot.lecture.lectureNotice.noticeMessage}" /></h3>
    <h4><fmt:formatDate value="${lectureTimeSlot.beginTime}" type="both" dateStyle="full"
      timeStyle="full" /> <br />
    <c:out value="${lectureTimeSlot.reservedPlace}" /></h4>
    <p><i>Abstract: </i><c:out value="${lectureTimeSlot.lecture.topicAbstract}" /></p>
    <h4>Lecture coordinator: <c:out value="${lectureTimeSlot.lecture.lectureCoordinator.name}" />
    / <c:out value="${lectureTimeSlot.lecture.lectureCoordinator.email}" /> / <c:out
      value="${lectureTimeSlot.lecture.lectureCoordinator.phone}" /></h4>
    </td>
  </tr>

  <tr>
    <td><c:set var="reservationType_notAvailable" value="not available" /> <c:set
      var="reservationType_lecture" value="lecture" /> <c:set var="reservationType_meeting"
      value="meeting with individual" /> <c:set var="reservationType_unknown" value="unknown" />

    <table class="table_schedule_list" width="100%">
      <thead>
        <tr>
          <th colspan="3">Time Slots</th>
          <th width="50">Note</th>
          <th>Name</th>
          <th>Email</th>
          <th>Phone</th>
          <th></th>
        </tr>
      </thead>

      <tbody>
        <c:forEach items="${timeSlots}" var="timeSlot">
          <tr>
            <td><span><fmt:formatDate value="${timeSlot.beginTime}" type="time"
              timeStyle="short" /></span></td>
            <td>-</td>
            <td><span><fmt:formatDate value="${timeSlot.endTime}" type="time"
              timeStyle="short" /></span></td>

            <td><c:out value="${timeSlot.description}" /></td>

            <c:choose>
              <c:when test="${timeSlot.reservationType.description == reservationType_notAvailable}">
                <td colspan="4"><i>Not available</i></td>
              </c:when>

              <c:when test="${timeSlot.reservationType.description == reservationType_lecture}">
                <td colspan="3" class="td_title"><c:out value="${timeSlot.lecture.topic}" /></td>
                <td><c:out value="${timeSlot.reservedPlace}" /></td>
              </c:when>

              <c:when test="${timeSlot.reservationType.description == reservationType_meeting}">
                <c:choose>

                  <c:when test="${timeSlot.accountLogin != null}">
                    <form:form method="post">
                      <input type="hidden" name="timeSlotId" value="${timeSlot.internalId}" />
                      <input type="hidden" name="commandType" value="cancel" />
                      <td><c:out value="${timeSlot.accountLogin.accountInfo.name}" /></td>
                      <%
                         if( null != session.getAttribute( LoginController.attr_isAdmin ) )
                                           {
                      %>
                      <td><c:out value="${timeSlot.accountLogin.email}" /></td>
                      <%
                         } else
                                           {
                      %>
                      <td><a class="a_emailaddress" title="Complete email address is hidden."><c:out
                        value="${fn:substring ( timeSlot.accountLogin.email, 0, 10)}" />...</a></td>
                      <%
                         }
                      %>
                      <td><c:out value="${timeSlot.accountLogin.accountInfo.phone}" /></td>
                      <td><input type="submit" value="Cancel Time Slot"></td>
                    </form:form>
                  </c:when>

                  <c:when test="${timeSlot.accountInfo != null}">
                    <form:form method="post">
                      <input type="hidden" name="timeSlotId" value="${timeSlot.internalId}" />
                      <input type="hidden" name="commandType" value="cancel" />
                      <td><c:out value="${timeSlot.accountInfo.name}" /></td>
                      <td></td>
                      <td><c:out value="${timeSlot.accountInfo.phone}" /></td>
                      <td><input type="submit" value="Cancel Time Slot"></td>
                    </form:form>
                  </c:when>

                  <c:otherwise>
                    <form:form method="post">
                      <input type="hidden" name="timeSlotId" value="${timeSlot.internalId}" />
                      <input type="hidden" name="commandType" value="reserve" />
                      <td><input type="text" size="10" name="reservingPersonName" /></td>
                      <td><input type="text" size="15" name="reservingPersonEmail" /></td>
                      <td><input type="text" size="10" name="reservingPersonPhone" /></td>
                      <td><input type="submit" value="Reserve Time Slot"></td>
                    </form:form>
                  </c:otherwise>

                </c:choose>
              </c:when>

              <c:when test="${timeSlot.reservationType.description == reservationType_unknown}">
                <td colspan="5"><i>unknown schedule</i></td>
              </c:when>

            </c:choose>
          </tr>
        </c:forEach>
      </tbody>
    </table>
    </td>
  </tr>

  <tr>
    <td align="center">
    <form>Email schedule to : <input type="text"> <input type="submit" value="send"></form>
    </td>
  </tr>
</table>

